package com.klun.aop.JDKProxy1;

import java.lang.reflect.Proxy;

public class JdkProxyHandler {
    private Object realStar;
    public JdkProxyHandler(Object star){
        super();
        this.realStar = star;

    }
    public Object getProxyInstance(){
        return Proxy.newProxyInstance(
                realStar.getClass().getClassLoader(), //参数一，指定当前目标对象的类加载器
                realStar.getClass().getInterfaces(), // 目标对象实现的接口类型
                ((proxy, method, args) -> {
                    System.out.println("先进行代理谈判");
                    Object invoke = method.invoke(realStar, args);
                    System.out.println("演出完成");
                    return invoke;
                })
        );
    }
}

